import java.io.IOException;
import java.net.Socket;

/**
 * Usage: TravelAgent <NameServer port number> <NameServer hostname> <Manual or Automatic>
 * Port must between 1024-65535
 * @author Mali
 *
 */
public class TravelAgent {

	/**
	 * @param args
	 * args[1]: port number
	 * args[2]: hostname
	 * args[3]: Manual or Automatic
	 */
	public static void main(String[] args) {
		String hostName = null;
		int port = 0;
		Boolean AutoOn = false;
		Socket t_socket = null;
		
		/**BEGIN ARGUMENT VERIFICATION**/
		//Number of arguments check
		if(args.length != 4){
			System.err.println("Invalid command line arguments for TravelAgent\n");
			System.exit(1);
		}
		//Check the port number
		try{
			port = Integer.parseInt(args[1]);
		}catch(Exception e){
			System.err.println("Invalid command line arguments for TravelAgent\n");
			System.exit(1);
		}
		if(port<1024 || port >65535){
			System.err.println("Invalid command line arguments for TravelAgent\n");
			System.exit(1);
		}
		hostName = args[2];
		//Check if Manual/Automatic argument
		if(args[3].trim() == "Manual"){
			AutoOn = false;
		}else if(args[3].trim() == "Automatic"){
			AutoOn = true;
		}else{
			System.err.println("Invalid command line arguments for TravelAgent\n");
			System.exit(1);
		}
		/**END OF ARGUMENT VERIFICATION**/
		
		/**Connect to Name Server**/
		
		try{
			t_socket = new Socket(hostName, port);
		}catch(Exception e){
			
		}
	}

}
